<%@ page language="java" import="java.util.List" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
	<head>
		<html:base />
		<title>Search Poster</title>
		<link href="login.css" rel="stylesheet" type="text/css">
	</head>
  
	<body>
    	<logic:notPresent name="posters" scope="session">
			<logic:redirect page="/illegal_access.jsp"></logic:redirect>
		</logic:notPresent>
		<logic:notPresent name="page" scope="session">
			<logic:redirect page="/illegal_access.jsp"></logic:redirect>
		</logic:notPresent>
    	<% 
			int current_offset=(Integer) session.getAttribute("page");
			int list_size=((List) session.getAttribute("posters")).size();
			int current_end=current_offset+10;
			pageContext.setAttribute("co", current_offset);
		 %>
		<div class="container">
			<div class="header">
				<html:img page="/yssz.jpg"/>
				<div id="login">
					<html:link action="mainPre">main page</html:link>
					<html:link page="/form/search.jsp">back to search engine</html:link>
				</div>
			</div>
			<div class="content">
				<h1>Search Poster</h1>
				<logic:iterate id="posterList" name="posters" scope="session" length="10" offset="co">
					<div class="floor">
						<p><bean:write name="posterList" property="topic_name"/></p>
						<h5>
							<logic:equal name="posterList" property="is_doctor" value="1">Dr. </logic:equal>
							<bean:write name="posterList" property="user_name"/>
							<logic:present name="admin" scope="session">
								<bean:define id="poster_id" name="posterList" property="posterid"></bean:define>
								<a href="/se3/deletePoster.do?posterid=<%=poster_id %>">delete</a>
							</logic:present>
						</h5>
						<p><bean:write name="posterList" property="content"/></p>
						<p class="time"><bean:write name="posterList" property="create_time"/></p>
					</div>
				</logic:iterate>
				<% 
					boolean have=false;
					if(current_offset!=0) {
						out.write("<a href=\"/se3/firstPage.do?from=search_poster\">首页</a> ");
						out.write("<a href=\"/se3/previewPage.do?from=search_poster\">上一页</a> ");
						have=true;
					}
					if(current_end<list_size) {
						out.write("<a href=\"/se3/nextPage.do?from=search_poster\">下一页</a> ");
						out.write("<a href=\"/se3/lastPage.do?from=search_poster&size="+list_size+"\">末页</a>");
						
					}
				 %>
				</div>
			<div class="footer">
				<p>copyright@yssz</p>
			</div>
		</div>
	</body>
</html:html>
